// 项目业务请求接口
import request from "./request";

// 封装登录接口
export function loginApi(data) {
    return request({
        url: "/login",
        method: "POST",
        data,
    });
}

// 封装左侧菜单栏的渲染
export function zuolist() {
    return request({
        url: "/menus",
        method: "GET",
    });
}

// 封装用户模块数据渲染
export function userlist(params) {
    return request({
        url: "/users",
        method: "GET",
        params,
    });
}

// 添加用户的接口
export function adduser(data) {
    return request({
        url: "/users",
        method: "POST",
        data,
    });
}

// 用户删除的接口
export function delmore(id) {
    return request({
        url: "/users/" + id,
        method: "DELETE",
    });
}

// 用户编辑的修改
export function edituser(data) {
    return request({
        url: "/users/" + data.id,
        method: "PUT",
        data,
    });
}

// 用户改变状态的方法
export function changestatus(data) {
    return request({
        url: `/users/${data.id}/state/${data.mg_state}`,
        method: "put",
    });
}
// 封装分配用户角色
export function getfpjs(id, rid) {
    return request({
        url: `/users/${id}/role`,
        method: "PUT",
        data: { rid },
    });
}

// 渲染权限rights的接口
export function getrights(type = "list") {
    return request({
        url: `/rights/${type}`,
        method: "GET",
    });
}

// 渲染roles的接口
export function userroles() {
    return request({
        url: "/roles",
        method: "GET",
    });
}

// 添加角色的接口
export function addroles(data) {
    return request({
        url: "/roles",
        method: "POST",
        data,
    });
}

// 编辑角色的接口
export function edroles(data) {
    return request({
        url: `/roles/${data.id}`,
        method: "put",
        data,
    });
}

// 封装角色删除的接口
export function delroles(id) {
    return request({
        url: `roles/${id}`,
        method: "delete",
    });
}

// 封装goods商品列表的接口
export function goodslist(params) {
    return request({
        url: "/goods",
        method: "GET",
        params,
    });
}

// 封装goods商品删除的方法
export function delgoods(id) {
    return request({
        url: `goods/${id}`,
        method: "DELETE",
    });
}
// 编辑的商品id
export function editgoods(data) {
    return request({
        url: `/goods/${data.goods_id}`,
        method: "PUT",
        data,
    });
}

// 渲染商品分类管理全部数据
export function getcate() {
    return request({
        url: "/categories",
        method: "GET",
    });
}

// 封装商品分类添加的接口
export function addcate(data) {
    return request({
        url: "/categories",
        method: "POST",
        data,
    });
}

// 角色授权id
export function roleshouquan(roleId, rids) {
    return request({
        url: `roles/${roleId}/rights`,
        method: "POST",
        data: { rids },
    });
}

// 删除角色授权中的某一项
export function deljues(roleId, rightId) {
    return request({
        url: `roles/${roleId}/rights/${rightId}`,
        method: "DELETE",
    });
}

// 获取商品分类数据列表
export function getgoodslist(params) {
    return request({
        url: "/categories",
        method: "GET",
        params,
    });
}
//获取参数列表的数据
export function getcanshulist(id, sel = "many") {
    return request({
        url: `/categories/${id}/attributes`,
        method: "GET",
        params: { sel },
    });
}

// 添加到商品列表
export function addgoods(data) {
    return request({
        url: "/goods",
        method: "POST",
        data,
    });
}

// 编辑的商品列表的接口
export function editlist(id, cat_name) {
    return request({
        url: `categories/${id}`,
        method: "PUT",
        data: { cat_name },
    });
}

// 删除商品列表的数据
export function dellist(id) {
    return request({
        url: `categories/${id}`,
        method: "DELETE",
    });
}

// 渲染订单列表
export function getorder(params) {
    return request({
        url: "/orders",
        method: "GET",
        params,
    });
}

// 物流进度
export function getorderwl(id) {
    return request({
        url: `/kuaidi/${id}`,
        method: "GET",
    });
}

// 图标的方法
export function gettb() {
    return request({
        url: `reports/type/1`,
        method: "GET",
    });
}

// 添加标签的方法
export function addtag(id, attrId, data) {
    return request({
        url: `categories/${id}/attributes/${attrId}`,
        method: "PUT",
        data,
    });
}

// 删除标签的方法
export function deltag(id, attrId) {
    return request({
        url: `categories/${id}/attributes/${attrId}`,
        method: "DELETE",
    });
}

// 添加动态参数或者静态参数
export function adddjlist(data) {
    return request({
        url: `categories/${data.id}/attributes`,
        method: "POST",
        data,
    });
}